package vcp.client.reports;

import java.io.Serializable;

import org.joda.time.format.DateTimeFormat;

import vcp.entity.PeriodicReport;
import vcp.enums.ReportType;

public class QuarterReports extends ReportAbstract
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3876555486754468022L;

	public QuarterReports ()
	{
		super(ReportType.QUARTERS);
	}

	// ****************************************************************************************************************************
	// Public methods
	// ****************************************************************************************************************************
	public void add ( PeriodicReport periodic )
	{
		PeriodicReportRow periodicReportRow = new PeriodicReportRow();
		periodicReportRow.setReportID(periodic.getID());
		periodicReportRow.setPeriodicReportType(periodic.getType().toString());
		periodicReportRow.setStartDate(DateTimeFormat.forPattern("dd/MM/yyyy").print(periodic.getStartDate()));
		periodicReportRow.setEndDate(DateTimeFormat.forPattern("dd/MM/yyyy").print(periodic.getEndDate()));
		periodicReportRow.setSiteName(periodic.getSite().toString());

		this.reportDataRow.add(periodicReportRow);
	}

	// ****************************************************************************************************************************
	// ReportAbstract methods
	// ****************************************************************************************************************************
	@Override
	public String[] getHeaders ()
	{
		return new String[]
			{ "Report ID"
					, "Periodic Report type"
					, "Start Period"
					, "End Period"
					, "Site" };
	}

	// ****************************************************************************************************************************
	// Private class
	// ****************************************************************************************************************************

	/**
	 * 
	 * @author VCP team
	 *         <p>
	 *         periodic report row wrapper class
	 */
	private class PeriodicReportRow implements Serializable, IWrapperConverter
	{
		/**
		 * 
		 */
		private static final long serialVersionUID = - 8783399642490359948L;
		// ****************************************************************************************************************************
		// Setter-Getter methods
		// ****************************************************************************************************************************
		private String siteName;

		/**
		 * 
		 * @return site name
		 */
		public String getSiteName ()
		{
			return this.siteName;
		}

		/**
		 * set site name
		 * 
		 * @param siteName
		 */
		public void setSiteName ( String siteName )
		{
			this.siteName = siteName;
		}

		private String endDate;

		/**
		 * 
		 * @return periodic report end date
		 */
		public String getEndDate ()
		{
			return this.endDate;
		}

		/**
		 * set periodic report end date
		 * 
		 * @param endDate
		 */
		public void setEndDate ( String endDate )
		{
			this.endDate = endDate;
		}

		private String startDate;

		/**
		 * 
		 * @return report periodic start date
		 */
		public String getStartDate ()
		{
			return this.startDate;
		}

		/**
		 * set periodic report start date
		 * 
		 * @param startDate
		 */
		public void setStartDate ( String startDate )
		{
			this.startDate = startDate;
		}

		private String periodicReportType;

		/**
		 * 
		 * @return get periodic report type
		 */
		public String getPeriodicReportType ()
		{
			return this.periodicReportType;
		}

		/**
		 * set periodic report type
		 * 
		 * @param periodicReportType
		 */
		public void setPeriodicReportType ( String periodicReportType )
		{
			this.periodicReportType = periodicReportType;
		}

		private Integer reportID;

		/**
		 * 
		 * @return report ID
		 */
		public Integer getReportID ()
		{
			return this.reportID;
		}

		/**
		 * set reports new ID
		 * 
		 * @param reportID
		 */
		public void setReportID ( Integer reportID )
		{
			this.reportID = reportID;
		}

		// ****************************************************************************************************************************
		// IWrapperConverter class
		// ****************************************************************************************************************************
		@Override
		public Object[] toObjectArray ()
		{
			return new Object[]
				{ this.getReportID()
						, this.getPeriodicReportType()
						, this.getStartDate()
						, this.getEndDate()
						, this.getSiteName() };
		}

	}
}
